//
//  BaseChecklistTableView.swift
//  GreenDeal
//
//  Created by Moennig Q on 2023/4/19.
//
import UIKit
import RxSwift
import RxCocoa
import RxRelay
import RxDataSources
enum ChecklistType: String {
    case Image = "image"
    case Text = "text"
    case Bool = "boolean"
    case PanelInstalled = "panelInstalled"
    case DerRegister = "derRegister"
    case header = "header"//分组section的抬头,只有section title
    case headerWithImage = "headerWithImage"//分组section的抬头，包括section title和top image
    case All = ""
}

class BaseChecklistTableView: TableView {
    lazy var disposeBag = DisposeBag()
    static var checklistCellHeight: CGFloat = 54
    var toSignatureClosure: ((SignatureType)->Void)?
    var toPanelListClickClosure: (()->Void)?
    var toInverterListClickClosure: (()->Void)?
    var toPanelInstallClosure: (()->Void)?
    var toDERRegisterClosure: (()->Void)?
    var toImageListClosure: ((_ index: Int)->Void)?
    var toEditTextClosure: ((_ checklistModel: PVDChecklistModel)->Void)?
    var toClickChecklitBoolItemClosure: ((_ index: Int)->Void)?
    var toTankListClickClosure: (()->Void)?
    
    override func setUpView() {
        self.backgroundColor = UIColor(hexStr: Constant.TransparentColorHexStr)
        self.isScrollEnabled = false
        //
        self.register(PVDDetailChecklistSelfieCell.self, forCellReuseIdentifier: PVDDetailChecklistSelfieCell.reuseCellIdentifier)
        self.register(PVDDetailChecklistScanCell.self, forCellReuseIdentifier: PVDDetailChecklistScanCell.reuseCellIdentifier)
        self.register(ChecklistHeaderWithSectionImageCell.self, forCellReuseIdentifier: ChecklistHeaderWithSectionImageCell.reuseCellIdentifier)
        self.register(PVDDetailChecklistHeaderCell.self, forCellReuseIdentifier: PVDDetailChecklistHeaderCell.reuseCellIdentifier)
        self.register(PVDDetailChecklistTableViewCell.self, forCellReuseIdentifier: PVDDetailChecklistTableViewCell.reuseCellIdentifier)
        self.register(PVDDetailSignatureTableViewCell.self, forCellReuseIdentifier: PVDDetailSignatureTableViewCell.reuseCellIdentifier)
        self.register(PVDDetailChecklistCertificatedCell.self, forCellReuseIdentifier: PVDDetailChecklistCertificatedCell.reuseCellIdentifier)
        self.estimatedRowHeight = 80;//从50改成80 解决上传附件后返回detail 后，布局位置改变的问题
        self.rowHeight = UITableView.automaticDimension
        if #available(iOS 15.0, *) {//iOS 15会默认有22点的高度,需要代码设置为0
            self.sectionHeaderTopPadding = 0
        }
        //
        self.rx.itemSelected.bind { [weak self] (indexPath) in
            guard let strongSelf = self else {return}
            strongSelf.operateChecklist(indexPath.row)
        }.disposed(by: self.disposeBag)
        //
        self.bindData()
    }
    //MARK: - 绑定checklist 数据源
    func bindData(){
        
    }
    //MARK: - 操作某一行
    func operateChecklist(_ row: Int){
       
    }
    
}
